﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QuestionInputModels>" %>

<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>
<%@ Import Namespace="ChoViet.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Trả lời
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <fieldset>
        <legend>Thông tin chi tiết câu hỏi</legend>
        <table class="admintable" width="100%">
            <tbody>
                <tr>
                    <td class="key">
                        Chuyên mục
                    </td>
                    <td>
                        <%= Model.Question.CatID.HasValue ? Model.Question.QuestionCategory.Name : "--"%>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Tiêu đề
                    </td>
                    <td>
                        <%= Model.Question.Title %>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Nội dung
                    </td>
                    <td>
                        <%= Model.Question.QuestionContent %>
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
    <fieldset>
        <legend>Thông tin các câu trả lời</legend>Hiện có
        <%= Model.Question.nAnswers %>
        câu trả lời.<br />
        <% if (Model.ListAnswer != null && Model.ListAnswer.Count() > 0)
           {
               foreach (var a in Model.ListAnswer)
               {
        %>
        <div style="border-bottom: 1px dashed #999;">
        </div>
        <table class="admintable" width="100%">
            <tbody>
                <tr>
                    <td class="key">
                        Nội dung câu trả lời
                    </td>
                    <td>
                        <%= a.Answers %>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Ngày gửi
                    </td>
                    <td>
                        <%= a.AddDate %>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Người gửi
                    </td>
                    <td>
                        <%= string.IsNullOrEmpty(a.AnswerName) ? a.aspnet_User.UserName : a.AnswerName %>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Email
                    </td>
                    <td>
                        <%= string.IsNullOrEmpty(a.AnswerEmail) ? a.aspnet_User.aspnet_Membership.Email: a.AnswerEmail%>
                    </td>
                </tr>
            </tbody>
        </table>
        <%}
           } %>
           <table width="100%">
            <tr>
                <td align="center">
                    <div class="pager">
                        <%= Html.Pager(Model.ListAnswer.PageSize, Model.ListAnswer.PageNumber, Model.ListAnswer.TotalItemCount)%>
                    </div>
                </td>
            </tr>
        </table>
    </fieldset>
    <% using (Html.BeginForm("Answer", "Question", FormMethod.Post, new
       {
           id = "adminForm",
           enctype = "multipart/form-data"
       }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <fieldset>
        <legend>Nội dung câu trả lời</legend>
        <table class="admintable" width="100%">
            <tbody>
                <tr>
                    <td class="key">
                        Nội dung (<font color="red">*</font>)
                    </td>
                    <td>
                        <%=Html.TextArea("Answers", string.Empty, new { cols = 90, rows = 20 })%>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Trạng thái
                    </td>
                    <td>
                        <%= Html.RadioButton("PubYN", true, new { @checked = "checked" })%>
                        Đăng tin
                        <%= Html.RadioButton("PubYN", false)%>
                        Không đăng
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        Trạng thái kiểm tra
                    </td>
                    <td>
                        <%= Html.RadioButton("CheckYN", true, new { @checked = "checked" })%>
                        Đã kiểm tra
                        <%= Html.RadioButton("CheckYN", false)%>
                        Chưa kiểm tra
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="hidden" id="nViews" name="nViews" value="0" />
                        <input type="hidden" id="QuestionID" name="QuestionID" value="<%= Model.Question.ID %>" />
                        <input type="hidden" id="AddDate" name="AddDate" value="<%= DateTime.Now %>" />
                        <input type="submit" id="Submit" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                    </td>
                </tr>
            </tbody>
        </table>
    </fieldset>
    <%}
      } %>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
        });

        tinyMCE.init({
            mode: "exact",
            elements: "Answers",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,cleanup,help,code,|,insertdate,inserttime,preview",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
        <%= Html.Toolbar("Quay lại", "/Question/Details/" + Model.Question.ID, "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Trả lời
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
